<script type="text/javascript">
    var id=0;var wd=new Array(7);wd[0]="Sun";wd[1]="Mon";wd[2]="Tue";wd[3]="Wed";wd[4]="Thu";wd[5]="Fri";wd[6]="Sat";function pad2(number){return (number<10?'0':'')+number;}
    function moreShow(){$("#mr").hide(function(){$("#lg").show(function(){more();});});}
    function more(){id+=10;$.getJSON("<?php echo base_url();?>main/getjson/"+id,function(data){$.each(data,function(i,item){no=$('.story-item').last().clone();no.find('.digg-button').html("Rp. "+item.expense_amount);no.find('.story-item-title').html(item.expense_title);t=item.expense_date.split("-");t1=t[2].split(" ");t2=t1[1].split(":");d=new Date(t[0],(t[1]-1),t1[0],t2[0],t2[1],t2[2],0);no.find('.story-item-source').html("in "+item.category_title+" At "+wd[d.getDay()]+", "+pad2(d.getDate())+"/"+pad2((d.getMonth())+1)+"/"+d.getFullYear()+" "+pad2(d.getHours())+":"+pad2(d.getMinutes())+" WIB");$('.story-item').last().after(no);});$("#lg").hide(function(){$("#mr").show();});if(id>=50){$("#moreExpense").hide();}})}
    function del(obj,id){$.get('<?php echo base_url();?>main/delete/'+id,function(data){if(data!="false"){obj=$(obj).parents(".story-item");$(obj).slideUp(function(){$(obj).remove();});}});}
</script>
<div id="expenseHome">
    <?php if ($this->session->flashdata('add_status')) : ?>
    <div id="submitOk">
        <span>
            Item Has Been Added
        </span>
    </div>
    <?php endif;?>
    <div id="thisMonth">
        <div class="list-header">
            <h2>
                This Month : Rp. <?php echo number_format($this_month, 0, ',', '.');?>
            </h2>
        </div>
    </div>
    <div class="story-item-header">
        <h2>
            Last Item
        </h2>
    </div>
    <div id="lastExpense">
        <div id="lastExpense-wrap">
        <?php foreach ($last_item->result() as $row) : ?>
        <div class="story-item">
            <div class="story-item-content">
                <span class="digg-button">
                    Rp. <?php echo number_format($row->expense_amount, 0, ',', '.');?>
                </span>
                <span title="delete this expense" class="delete-button" onclick="del(this,<?php echo $row->expense_id;?>)">
                    [x]
                </span>
                <a class="story-item-biglink">
                    <span class="story-item-title">
                        <?php echo $row->expense_title;?>
                    </span>
                </a>
                <p class="story-item-description">
                    <span class="story-item-source">
                        in <?php echo $row->category_title;?> At <?php echo date("D, d/m/Y H:i", strtotime($row->expense_date));?> WIB
                    </span>
                </p>
            </div>
        </div>
        <?php endforeach;?>
        </div>
        <div id="moreExpense" onclick="moreShow()">
            <p id="mr">MORE</p>
            <p id="lg" class="none"><img src="<?php echo base_url();?>script/al-1.2.gif"/></p>
        </div>
    </div>
</div>